package com.shhic.hhplt.server.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.shhic.hhplt.server.model.User;
import com.shhic.hhplt.server.model.Workbay;
import com.shhic.hhplt.server.model.WorkbayState;
import com.shhic.hhplt.server.model.WorkbayStateQuery;
import com.shhic.hhplt.server.mapper.IUserDao;
import com.shhic.hhplt.server.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@DS("hhpltSys")
@Transactional
public class UserServiceImpl  implements IUserService {

    @Autowired
    private IUserDao userDao;

    @Override
    public User getUser(String username, String password) {
        return userDao.getUser(username, password);
    }

    @Override
    public void updateUserPassword(String username, String newpassword) {
        userDao.updateUserPassword(username,newpassword);
    }

    @Override
    public List<String> getAllProductList() {
        return userDao.getAllProductList();
    }

    @Override
    public void registerProductAndSuite(String product, String suite) {
        if(userDao.checkIfExistsProductAndSuite(product,suite) == 0){
            userDao.insertProductAndSuite(product,suite);
        }
    }

    @Override
    public List<String> getAllTestorNameList() {
        return userDao.getAllTestorNameList();
    }

    @Override
    public List<String> getSuiteList(String productName) {
        return userDao.getSuiteList(productName);
    }

    @Override
    public void deleteUser(String username) {
        userDao.deleteUser(username);
    }

    @Override
    public List<User> getAllUser() {
        return userDao.getAllUser();
    }

    @Override
    public void insertUser(User user) {
        userDao.insertUser(user);
    }

    @Override
    public void deleteWorkbay(String workbayId) {
        userDao.deleteWorkbay(workbayId);
    }

    @Override
    public List<Workbay> getAllWorkbay() {
        return userDao.getAllWorkbay();
    }
    @Override
    public void insertWorkbay(Workbay workbay) {
        userDao.insertWorkbay(workbay);
    }

    @Override
    public void saveWorkbayState(WorkbayState workbayState) {
        userDao.insertWorkbayState(workbayState);
    }

    @Override
    public List<WorkbayState> queryHistoryWorkbayState(WorkbayStateQuery query) {
        return userDao.queryHistoryWorkbayState(query);
    }

}
